package com.googlecode.horncomb.orm.support.order;

import java.io.Serializable;


import static org.apache.commons.lang.Validate.*;

/**
 * 排序对象
 * @author Daniel
 */
public class SortTokenImpl implements Serializable, SortToken {
	private static final long serialVersionUID = 2446198126536792567L;
	private String property;
	private boolean ascending;

	public SortTokenImpl() {
		super();
	}

	public SortTokenImpl(String property, boolean ascending) {
		super();
		notEmpty(property);
		this.property = property;
		this.ascending = ascending;
	}

	/**
	 * @see com.googlecode.horncomb.orm.support.order.SortToken#isAscending()
	 */
	public boolean isAscending() {
		return ascending;
	}

	public void setAscending(boolean ascending) {
		this.ascending = ascending;
	}

	/**
	 * @see com.googlecode.horncomb.orm.support.order.SortToken#getProperty()
	 */
	public String getProperty() {
		notEmpty(property);
		return property;
	}

	public void setProperty(String name) {
		this.property = name;
	}
}
